package co.th.bjc.md.helper.impl;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import java.sql.PreparedStatement;

import co.th.bjc.md.helper.entries.HelperDatabse;

public class LoginHelper extends HelperDatabse {
	@SuppressWarnings("finally")
	public boolean verifyLogin(String username, String password) {
		boolean verify = false;
		Connection con = null;
		PreparedStatement pstmt = null;
		try{
			con = getConnection();
			String sql = "SELECT username FROM login WHERE username = '"+username+"' and password = '"+password+"'";
			pstmt = con.prepareStatement(sql);
			ResultSet rs = pstmt.executeQuery();
			if(rs.next()){
				verify = true;
			}
			pstmt.close();
			con.close();
			return verify;
		}catch(Exception ex){
			ex.printStackTrace();
		}finally{
			try {
				pstmt.close();
				con.close();
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return verify;
		}
		
	}
}
